(function(vc){
    vc.extends({
        propTypes: {
           emitChooseIntegralGoods:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseIntegralGoodsInfo:{
                integralGoodss:[],
                _currentIntegralGoodsName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseIntegralGoods','openChooseIntegralGoodsModel',function(_param){
                $('#chooseIntegralGoodsModel').modal('show');
                $that._refreshChooseIntegralGoodsInfo();
                $that._loadAllIntegralGoodsInfo(1,10,'');
            });
        },
        methods:{
            _loadAllIntegralGoodsInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('integralGoods.listIntegralGoodss',
                             param,
                             function(json){
                                var _integralGoodsInfo = JSON.parse(json);
                                $that.chooseIntegralGoodsInfo.integralGoodss = _integralGoodsInfo.integralGoodss;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseIntegralGoods:function(_integralGoods){
                if(_integralGoods.hasOwnProperty('name')){
                     _integralGoods.integralGoodsName = _integralGoods.name;
                }
                vc.emit($props.emitChooseIntegralGoods,'chooseIntegralGoods',_integralGoods);
                vc.emit($props.emitLoadData,'listIntegralGoodsData',{
                    integralGoodsId:_integralGoods.integralGoodsId
                });
                $('#chooseIntegralGoodsModel').modal('hide');
            },
            queryIntegralGoodss:function(){
                $that._loadAllIntegralGoodsInfo(1,10,$that.chooseIntegralGoodsInfo._currentIntegralGoodsName);
            },
            _refreshChooseIntegralGoodsInfo:function(){
                $that.chooseIntegralGoodsInfo._currentIntegralGoodsName = "";
            }
        }

    });
})(window.vc);
